<template>
  <div class="login-container">
    <el-container>
      <el-header style="display: flex;align-items: center;justify-content: center;">Header</el-header>
      <el-main>
        <el-row>
          <el-col :span="8">
            <div class="logo">
              <img src="../../assets/logo.svg" />
            </div>
            <h2 class="logo-title">欢迎登录</h2>
          </el-col>
        </el-row>
        <el-card class="box-card">
          <el-tabs v-model="activeName">
            <el-tab-pane label="账号密码登录" name="account">
              <el-form label-width="0">
                <el-form-item>
                  <el-input v-model="mobile" placeholder="账号/手机号" prefix-icon="el-icon-user"></el-input>
                </el-form-item>
                <el-form-item>
                  <el-input
                    v-model="password"
                    type="password"
                    placeholder="请输入密码"
                    prefix-icon="el-icon-lock"
                  ></el-input>
                </el-form-item>
                <el-form-item>
                  <div class="btn-container">
                    <el-button type="primary" @click="goLogin">登录</el-button>
                  </div>
                </el-form-item>
              </el-form>
            </el-tab-pane>
            <el-tab-pane label="手机密码登录" name="mobile">
              <el-form label-width="0">
                <el-form-item>
                  <el-input placeholder="手机号" prefix-icon="el-icon-user"></el-input>
                </el-form-item>
                <el-form-item>
                  <el-input placeholder="请输入图像验证码" prefix-icon="el-icon-picture-outline"></el-input>
                </el-form-item>
                <div class="captcha">
                  <el-form-item>
                    <el-input placeholder="验证码" prefix-icon="el-icon-lock"></el-input>
                    <el-button type="primary">获取动态验证码</el-button>
                  </el-form-item>
                </div>
                <el-form-item>
                  <div class="btn-container">
                    <el-button type="primary">登录</el-button>
                  </div>
                </el-form-item>
              </el-form>
            </el-tab-pane>
          </el-tabs>
        </el-card>
      </el-main>
      <el-footer
        style="height:40px;display: flex;align-items: center;justify-content: center;"
      >DESIGNED BY ML</el-footer>
    </el-container>
  </div>
</template>

<script>
import Login from "@/api/login";

export default {
  data() {
    return {
      mobile: "",
      password: "",
      activeName: "account"
    };
  },
  methods:{
    async goLogin(){
      let apiData={
        'mobile':this.mobile,
        'password':this.password
      }
      let data=await Login.goLogin(apiData),
          token=data&&data.content?data.content:{};
      localStorage.setItem('Authorization', `Bearer ${token}`)
      this.$router.push({ path: `/home`, query: {} });
    }
  }
};
</script>

<style lang="scss" scoped>
.login-container {
  .el-header,
  .el-footer {
    background-color: #fff;
    color: #888;
    text-align: center;
    font-size: 12px;
    border: 1px solid #f4f4f4;
  }

  .el-header {
    background-color: #e9eef3;
  }

  .el-main {
    background-color: #e9eef3;
    color: #333;
    padding: 0;

    .el-row {
      background-color: #fff;

      .el-col {
        background-color: #fff;
        padding: 20px 0px;
        display: flex;

        .logo {
          width: 50%;
          height: 50px;
          margin-left: 40px;
          padding-right: 20px;
          border-right: 2px solid #ccc;

          img {
            width: 100%;
            height: 100%;
          }
        }

        .logo-title {
          margin-left: 20px;
          margin-top: 10px;
        }
      }
    }

    .box-card {
      float: right;
      margin-right: 20px;
      margin-top: 20px;
      height: 60vh;
      width: 28vw;

      .el-form {
        margin-top: 20px;

        .btn-container {
          width: 100%;

          /deep/ .el-button {
            width: 100%;
          }
        }
      }

      // .clearfix::before,
      // .clearfix::after{
      //   display: table;
      //   content: '';
      // }
      .text {
        font-size: 14px;
      }

      .item {
        margin-bottom: 18px;
      }
    }
  }

  .el-container {
    height: 100vh;
  }
}
</style>
